package com.hmall.user.controller.inner;

import com.hmall.user.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zzw
 * @date 2025/6/20
 * @description 用户内部接口
 */
@Api(tags = "用户内部接口")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/inner/users")
public class UserInnerController {

    private final IUserService userService;

    @ApiOperation("扣减余额")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id"),
            @ApiImplicitParam(name = "pw", value = "用户密码"),
            @ApiImplicitParam(name = "amount", value = "扣减金额")
    }
    )
    @PutMapping("/money/deduct")
    public void deductMoney(@RequestParam("userId") Long userId, @RequestParam("pw") String pw,
                            @RequestParam("amount") Integer amount) {
        userService.deductMoney(userId, pw, amount);
    }
}
